<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div id="subTree">
    <form action="">
        <input type="text">
    </form>
    <p>Paragraph</p>
    <span>span</span>
    <script src="Promise1.js"></script>
    <script src="Promise2.js"> </script>
    <script>
        function traverseDom(element, callback) {
            callback(element);
            element = element.firstElementChild;
            while (element){
                traverseDom(element, callback);
                element = element.nextElementSibling;
            }
        }
        const subtree = document.getElementById("subTree");
        // traverseDom(subtree, function (element) {
        //     console.log(element.nodeName);
        // });

        function* DomTravelsal(element) {
            yield element;
            element = element.firstElementChild;
            while (element){
                yield* DomTravelsal(element);
                element = element.nextElementSibling;
            }
        }
        for(let element of DomTravelsal(subtree)) {
            console.log(element.nodeName);
        }
        main('http://localhost:3000/json/1.json').then(a=>{console.log(a)})
    </script>
</div>
</body>
</html>